package com.znh.kuiklyuniversity.compose.widgets

import androidx.compose.runtime.Composable
import com.tencent.kuikly.compose.ComposeContainer
import com.tencent.kuikly.compose.coil3.rememberAsyncImagePainter
import com.tencent.kuikly.compose.foundation.Image
import com.tencent.kuikly.compose.foundation.clickable
import com.tencent.kuikly.compose.foundation.layout.Arrangement
import com.tencent.kuikly.compose.foundation.layout.Column
import com.tencent.kuikly.compose.foundation.layout.Row
import com.tencent.kuikly.compose.foundation.layout.fillMaxWidth
import com.tencent.kuikly.compose.foundation.layout.height
import com.tencent.kuikly.compose.foundation.layout.padding
import com.tencent.kuikly.compose.foundation.layout.width
import com.tencent.kuikly.compose.foundation.shape.RoundedCornerShape
import com.tencent.kuikly.compose.material3.Text
import com.tencent.kuikly.compose.ui.Alignment
import com.tencent.kuikly.compose.ui.Modifier
import com.tencent.kuikly.compose.ui.draw.clip
import com.tencent.kuikly.compose.ui.graphics.Color
import com.tencent.kuikly.compose.ui.layout.ContentScale
import com.tencent.kuikly.compose.ui.text.font.FontWeight
import com.tencent.kuikly.compose.ui.unit.dp
import com.tencent.kuikly.compose.ui.unit.sp
import com.tencent.kuikly.core.base.attr.ImageUri
import com.tencent.kuikly.core.module.RouterModule
import com.tencent.kuikly.core.nvi.serialization.json.JSONObject
import com.znh.kuiklyuniversity.ComposeRoutePager
import com.znh.kuiklyuniversity.backgroundColor
import com.znh.kuiklyuniversity.compose.selfenum.AppColor
import com.znh.kuiklyuniversity.height
import com.znh.kuiklyuniversity.padding
import com.znh.kuiklyuniversity.width

@Composable
fun UserView(ct: ComposeContainer) {

    Row(
        modifier = Modifier.fillMaxWidth()
            .clip(RoundedCornerShape(10.dp))
            .backgroundColor(Color.White),
        verticalAlignment = Alignment.CenterVertically
    ) {

        Image(
            painter = rememberAsyncImagePainter(ImageUri.SCHEME_COMMON_ASSETS + "commonimage/icon_temp.jpg"),
            contentScale = ContentScale.Fit,
            contentDescription = "",
            modifier = Modifier
                .width(100.dp)
                .height(100.dp)
                .clip(RoundedCornerShape(50.dp))
                .padding(10.dp)
                .clickable {
                    ct.acquireModule<RouterModule>(RouterModule.MODULE_NAME).openPage("detailpage", JSONObject().apply {
                        put("fromMainPage", "huawei")
                    })
                }
        )
        Column(
            modifier = Modifier.padding(start = 10.dp, end = 10.dp).fillMaxWidth(),
            verticalArrangement = Arrangement.Center
        ) {
            Row(horizontalArrangement =Arrangement.SpaceBetween ,
                modifier = Modifier.fillMaxWidth()){
                Text(
                    "曾南湖",
                    color = AppColor.TxtCom.color,
                    fontSize = 18.sp,
                    fontWeight = FontWeight.Bold
                )
                Image(painter = rememberAsyncImagePainter(ImageUri.SCHEME_COMMON_ASSETS+"icon/ic_action_overflow.png"),
                    contentDescription = "",
                    modifier = Modifier.width(18.dp)
                        .height(18.dp))
            }

            Text(
                "故乡安不了肉身，异乡安不了灵魂",
                color = AppColor.TxtCom.color,
                fontSize = 14.sp,
                modifier = Modifier.padding(top = 10.dp)
            )
        }
    }
}